define(["dojo/dom",
        "dojo/dom-style",
        "dojo/dom-geometry",
        "dojo/_base/fx"], function(dom,domStyle,domGeomtery,fx) {
	return {
		endLoading: function() {
            fx.fadeOut({
                node: dom.byId("loadingOverlay"),
                onEnd: function(node){
                    domStyle.set(node, "display", "none");
                }
            }).play();
        },
        startLoading: function(targetNode) {
            var overlayNode = dom.byId("loadingOverlay");
            if("none" == domStyle.get(overlayNode, "display")) {
                var coords = domGeometry.getMarginBox(targetNode || win.body());
                domGeometry.setMarginBox(overlayNode, coords);
                domStyle.set(overlayNode, {
                    display: "block",
                    opacity: 1
                });
            }
        }
	};
});